(function(vc){
    vc.extends({
        propTypes: {
           emitChooseAffiliateCommission:vc.propTypes.string,
           emitLoadData:vc.propTypes.string
        },
        data:{
            chooseAffiliateCommissionInfo:{
                affiliateCommissions:[],
                _currentAffiliateCommissionName:'',
            }
        },
        _initMethod:function(){
        },
        _initEvent:function(){
            vc.on('chooseAffiliateCommission','openChooseAffiliateCommissionModel',function(_param){
                $('#chooseAffiliateCommissionModel').modal('show');
                vc.component._refreshChooseAffiliateCommissionInfo();
                vc.component._loadAllAffiliateCommissionInfo(1,10,'');
            });
        },
        methods:{
            _loadAllAffiliateCommissionInfo:function(_page,_row,_name){
                var param = {
                    params:{
                        page:_page,
                        row:_row,
                        communityId:vc.getCurrentCommunity().communityId,
                        name:_name
                    }
                };

                //发送get请求
               vc.http.apiGet('affiliateCommission.listAffiliateCommission',
                             param,
                             function(json){
                                var _affiliateCommissionInfo = JSON.parse(json);
                                vc.component.chooseAffiliateCommissionInfo.affiliateCommissions = _affiliateCommissionInfo.affiliateCommissions;
                             },function(){
                                console.log('请求失败处理');
                             }
                           );
            },
            chooseAffiliateCommission:function(_affiliateCommission){
                if(_affiliateCommission.hasOwnProperty('name')){
                     _affiliateCommission.affiliateCommissionName = _affiliateCommission.name;
                }
                vc.emit($props.emitChooseAffiliateCommission,'chooseAffiliateCommission',_affiliateCommission);
                vc.emit($props.emitLoadData,'listAffiliateCommissionData',{
                    affiliateCommissionId:_affiliateCommission.affiliateCommissionId
                });
                $('#chooseAffiliateCommissionModel').modal('hide');
            },
            queryAffiliateCommissions:function(){
                vc.component._loadAllAffiliateCommissionInfo(1,10,vc.component.chooseAffiliateCommissionInfo._currentAffiliateCommissionName);
            },
            _refreshChooseAffiliateCommissionInfo:function(){
                vc.component.chooseAffiliateCommissionInfo._currentAffiliateCommissionName = "";
            }
        }

    });
})(window.vc);
